/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package mp3organizer;

import java.io.File;
import java.util.List;

/**
 *
 * @author Aderthad
 */
public class RenameSongs implements Actionable{

    @Override
    public void work(List<Mp3Orginizer.Album> albums) {
          for (Mp3Orginizer.Album al : albums) {
                for (Mp3Orginizer.Song s : al.getSongs()) {

                    if (!s.getPath().toFile().renameTo(new File(s.getPath().getParent().toString() + File.separator + String.format("%02d", Integer.parseInt(s.getTrackNum())) + ". " + s.getName() + ".mp3"))) {
                        System.out.println("ERROR: Couldn't move file " + s.getPath());
                        return;
                    }
                }

            }
    }
    
}
